package io.github.xbeeant.eoffice.rest;

import io.github.xbeeant.eoffice.antdesign.TreeNode;
import io.github.xbeeant.eoffice.model.User;
import io.github.xbeeant.eoffice.service.ITagService;
import io.github.xbeeant.eoffice.util.SecurityHelper;
import io.github.xbeeant.spring.security.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xiaobiao
 * @version 2021/7/6
 */
@RestController
@RequestMapping("api/tag")
public class TagRestController {

    @Autowired
    private ITagService tagService;

    @GetMapping
    public List<TreeNode> fetch() {
        LoginUser<User> userLoginUser = SecurityHelper.currentUser();
        return tagService.tags(userLoginUser.getUserId());
    }
}
